package com.event.mapper;

import com.event.pojo.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface  CategoryMapper {
    //新增
    @Insert("INSERT INTO category (CATEGORY_NAME, CATEGORY_ALIAS, CREATE_USER, CREATE_TIME, UPDATE_TIME) " +
            "VALUE (#{categoryName},#{categoryAlias},#{createUser},now(),now())")
    void add(Category category);

    //查询文章分类列表
    @Select("select * from category where create_user = #{id}")
    List<Category> queryList(Integer id);

    //文章分类详情查询
    @Select("select * from category where id = #{id}")
    Category detail(Integer id);

    //更新文章分类
    @Update("update category set category_name=#{categoryName},category_alias=#{categoryAlias},update_time=now() where id=#{id}")
    void updateCategory(Category category);

    //删除文章分类
    @Delete("delete from category where id = #{id}")
    void deleteCategoryById(Integer id);
}
